package com.fantasy.demo1.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fantasy.demo1.entity.Book;
import com.fantasy.demo1.mapper.BookMapper;
import com.fantasy.demo1.service.BookService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ET
 * @description TODO
 * @date 2021/7/29 10:46
 * @Version V1.0
 */
@Service
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements BookService {

    @Resource
    BookMapper bookMapper;

    @Override
    public List<Book> listAllByName(String name) {
        List<Book> books = bookMapper.selectAllByName(name);
        return books;
    }

    @Override
    public List<Book> condition(Book book) {
        LambdaQueryWrapper<Book> bookLambdaQueryWrapper = new LambdaQueryWrapper<>();
        bookLambdaQueryWrapper.like(Book::getName, book.getName())
                .eq(Book::getDescription, book.getDescription());
        List<Book> books = bookMapper.selectList(bookLambdaQueryWrapper);
        return books;
    }
}
